// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SA1109BlockStatementsMustNotContainEmbeddedRegionsBulbItem.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the SA1109BlockStatementsMustNotContainEmbeddedRegionsBulbItem type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace StyleCop.For.ReSharper.BulbItems.Readability
{
    #region Using Directives

    using JetBrains.ProjectModel;
    using JetBrains.ReSharper.Psi.CSharp.Tree;
    using JetBrains.TextControl;

    using StyleCop.For.ReSharper.BulbItems.Framework;
    using StyleCop.For.ReSharper.CodeCleanup.Rules;
    using StyleCop.For.ReSharper.Core;

    #endregion

    public class SA1109BlockStatementsMustNotContainEmbeddedRegionsBulbItem : V5BulbItemImpl
    {
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            var element = Utils.GetElementAtCaret(solution, textControl);
            var startRegionNode = element.GetContainingElement<IStartRegionNode>(true);
            if (startRegionNode != null)
            {
                ReadabilityRules.MoveRegionInsideNextOpenCurlyBracket(startRegionNode);
            }
        }
    }
}